package com.gancp.service.base;

import com.gancp.dao.base.IBaseMapper;

/**
 * @Author gancp
 * @Date 时间被黑洞吸走了
 * @Descripition 基础Service实现类
 **/
public abstract class BaseServiceImpl<T, K> implements BaseService<T, K> {

    protected abstract IBaseMapper getBaseMapper();

    @Override
    public int deleteByPrimaryKey(K id) {
        if (id == null) {
            return 0;
        }
        return getBaseMapper().deleteByPrimaryKey( id );
    }

    @Override
    public int insert(T record) {
        if (record == null) {
            return 0;
        }
        return getBaseMapper().insert( record );
    }

    @Override
    public int insertSelective(T record) {
        if (record == null) {
            return 0;
        }
        return getBaseMapper().insertSelective( record );
    }

    @Override
    public T selectByPrimaryKey(K id) {
        if (id == null) {
            return null;
        }
        return (T) getBaseMapper().selectByPrimaryKey( id );
    }

    @Override
    public int updateByPrimaryKeySelective(T record) {
        if (record == null) {
            return 0;
        }
        return getBaseMapper().updateByPrimaryKeySelective( record );
    }

    @Override
    public int updateByPrimaryKey(T record) {
        if (record == null) {
            return 0;
        }
        return getBaseMapper().updateByPrimaryKey( record );
    }

}
